/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package is202.hrms.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author MrVegard
 */
@Entity
public class Modulen implements Serializable {

    @Id
    @GeneratedValue
    private int modulenId;
    private String task;
    private String requirements;
    @Temporal(TemporalType.DATE)
    private Date dato;

    @OneToMany(mappedBy = "moduler")
    private List<Progress> progress;

    public Modulen() {
        progress = new ArrayList<Progress>();

    }

    public List<Progress> getProgress() {
        return progress;
    }

    public void setProgress(List<Progress> progress) {
        this.progress = progress;
    }

    public Date getDato() {
        return dato;
    }

    public void setDato(Date dato) {
        this.dato = dato;
    }

    public int getModulenId() {
        return modulenId;
    }

    public void setModulenId(int modulenId) {
        this.modulenId = modulenId;
    }

    public String getTask() {
        return task;
    }

    public void setTask(String task) {
        this.task = task;
    }

    public String getRequirements() {
        return requirements;
    }

    public void setRequirements(String requirements) {
        this.requirements = requirements;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 31 * hash + this.modulenId;
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Modulen other = (Modulen) obj;
        if (this.modulenId != other.modulenId) {
            return false;
        }
        return true;
    }

    public String timeOut(Date data) {
        Date date = new Date();

        if (date.before(data)) {
        //kan fortsatt ta modul

            return data.toString();
        } else {
            return "tiden har gått ut";
        }
    }

    public boolean timeOutBool(Date data) {
        Date date = new Date();

        if (date.before(data)) {
        //kan fortsatt ta modul

            return false;
        } else {
            return true;
        }
    }

}
